<html>
<head>
    <meta charset="UTF-8"/>
    <title>Sbody carving {:lang('ADMIN_CENTER')}</title>
    <meta http-equiv="X-UA-Compatible" content="chrome=1,IE=edge"/>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta name="robots" content="noindex,nofollow">
    <!-- HTML5 shim for IE8 support of HTML5 elements -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <![endif]-->
    <link href="__ADMIN_TMPL__/public/assets/themes/{:cmf_get_admin_style()}/bootstrap.min.css" rel="stylesheet">
    <link href="__STATIC__/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href="__ADMIN_TMPL__/public/assets/themes/{:cmf_get_admin_style()}/login.css" rel="stylesheet">
    <script>
        if (window.parent !== window.self) {
            document.write              = '';
            window.parent.location.href = window.self.location.href;
            setTimeout(function () {
                document.body.innerHTML = '';
            }, 0);
        }
    </script>
    <style>
        .form-group {
            margin-bottom: 0;
        }
        .form-group input {
            border: none;
            box-shadow:none;
        }
        .form-group:first-child{margin-top: 20px;}
        .form-group:nth-child(3){margin-bottom: 20px;}
        .form-group:first-child input {
            border-radius: 6px 6px 0 0;
        }
        .form-group:nth-child(3) input {
            border-radius: 0 0 6px 6px;
        }
        .h_title{padding-top: 30px;
            font-family: Helvetica,Arial,microsoft yahei,FreeSans,Arimo,droid sans,wenquanyi micro hei,hiragino sans gb,hiragino sans gb w3,FontAwesome,sans-serif;
            color: #fff;
            font-weight: 700;
            font-size: 40px;
            text-align: center;
            width: 100%;}
        .h_title span {
            color: #53d192;
        }
        .qhuan{
            width: 100%;
            text-align: center;
            padding: 9px 0;
            color: #fff;
            cursor: pointer;
        }
        .qhuan2{
            width: 100%;
            text-align: center;
            padding: 9px 0;
            color: #fff;
            cursor: pointer;
        }
        #sendOutCode{position: absolute;
            right: 0px;
            top: 0;
            width: 150px;
            height: 34px;
            border-radius: 0 0 6px 0;
            background: #ffffff;}
    </style>
</head>
<body style="background: #334054;">
<div class="wrap" >
    <div class="container">
        <div class="row">
            <div class="col-md-4 col-md-offset-4">
                <h1 class="text-center h_title">Sbody <span>carving</span></h1>
                <form class="js-ajax-form pass_login" action="{:url('admin/Public/doLogin')}" method="post">
                    <div>
                    <div class="form-group">
                        <input type="text" id="input_username" class="form-control" name="username"
                               placeholder="{:lang('USERNAME_OR_EMAIL')}" title="{:lang('USERNAME_OR_EMAIL')}"
                               value="{:cookie('admin_username')}" data-rule-required="true" data-msg-required="">
                    </div>

                    <div class="form-group">
                        <input type="password" id="input_password" class="form-control" name="password"
                               placeholder="{:lang('PASSWORD')}" title="{:lang('PASSWORD')}" data-rule-required="true"
                               data-msg-required="">
                    </div>

                    <div class="form-group">
                        <div style="position: relative;">
                            <input type="text" name="captcha" placeholder="验证码" class="form-control captcha">
                            <captcha height="32" width="150" font-size="18"  useCurve="false" useNoise="false" codeSet="0123456789"
                                     style="cursor: pointer;position:absolute;right:1px;top:1px;"/>
                        </div>
                    </div>
                    </div>
                    <div class="form-group">
                        <input type="hidden" name="redirect" value="">
                        <button class="btn btn-primary btn-block js-ajax-submit" type="submit" style="margin-left: 0px;width: 100%;border-radius: 6px;background: #53d192;border: 0;color: #fff;font-size: 14px;line-height: 30px;"
                                data-loadingmsg="{:lang('LOADING')}">
                            {:lang('LOGIN')}
                        </button>
                    </div>
                    <div class="form-group"><p class="qhuan">手机验证码登录</p></div>
                </form>
                <form class="js-ajax-form phone_login" action="{:url('admin/Public/doLogin2')}" method="post" style="display: none;">
                    <div>
                        <div class="form-group">
                            <input type="text" id="input_phone" class="form-control" name="phone"
                                   placeholder="请输入您的手机号" title="请输入您的手机号"
                                   value="" data-rule-required="true" data-msg-required="">
                        </div>


                        <div class="form-group" style="margin-bottom: 20px;">
                            <div style="position: relative;">
                                <input type="text" name="captcha" placeholder="手机验证码" class="form-control captcha" style=" border-radius: 0 0 6px 6px;">
                                <input type="button" id="sendOutCode" onclick="sendOutCode2();" value="获取动态码">
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <input type="hidden" name="redirect" value="">
                        <button class="btn btn-primary btn-block js-ajax-submit" type="submit" style="margin-left: 0px;width: 100%;border-radius: 6px;background: #53d192;border: 0;color: #fff;font-size: 14px;line-height: 30px;"
                                data-loadingmsg="{:lang('LOADING')}">
                            {:lang('LOGIN')}
                        </button>
                        <div class="form-group"><p class="qhuan2">密码登录</p></div>
                    </div>
                </form>
            </div>
        </div>

    </div>
</div>
<script>

    function sendOutCode2() {
        var mobile = $("#input_phone").val();
        //验证手机号格式是否正确
        if(mobile.search(/^1(3|4|5|7|8)\d{9}$/) == -1){
            $("#input_phone").trigger("focus");
            Wind.use( 'noty',function () {
                noty({
                    text: '请输入正确的手机号',
                    type: 'success',
                    layout: 'topCenter',
                    modal: true,
                    timeout: 800,
                }).show();
            })
            return false;
        }
        //验证手机号是否已经注册
        $.ajax({
            type: "POST",
            url: "{:url('admin/Public/send')}",
            data: {"username":mobile},
            success: function(data){
                Wind.use( 'noty',function () {
                    noty({
                        text: data.msg,
                        type: 'success',
                        layout: 'topCenter',
                        modal: true,
                        timeout: 800,
                    }).show();
                })
                if(data['code']==1){
                    time();
                }
            }
        });
    }

    var wait=120;
    function time() {
        if (wait == 0) {
            $("#sendOutCode").removeAttr("disabled");
            $("#sendOutCode").css("border", "1px solid #FF5073");
            $("#sendOutCode").css("color", "#ff6a88");
            $("#sendOutCode").val("获取验证码");
            wait = 120;
        } else {
            $("#sendOutCode").attr("disabled", 'disabled');
            $("#sendOutCode").css("border", "1px solid #ccc");
            $("#sendOutCode").css("color", "#ccc");
            $("#sendOutCode").val(wait+"s后重新发送");
            wait--;
            setTimeout(function() {
                    time()
                },
                1000)
        }
    }
</script>
<script type="text/javascript">
    //全局变量
    var GV = {
        ROOT: "__ROOT__/",
        WEB_ROOT: "__WEB_ROOT__/",
        JS_ROOT: "static/js/",
        APP: ''/*当前应用名*/
    };
</script>
<script src="__STATIC__/js/jquery.js"></script>
<script src="__STATIC__/js/wind.js"></script>
<script src="__STATIC__/js/admin.js"></script>
<script>
    (function () {
        document.getElementById('input_username').focus();
        $('.qhuan2').click(function () {

            $('.phone_login').hide(200,function(){ $('.pass_login').show(200); });
        })
        $('.qhuan').click(function () {

            $('.pass_login').hide(200,function(){ $('.phone_login').show(200); });
        })
    })();

</script>
</body>
</html>
